package pers.cz.resource;

import pers.cz.log.LogUtils;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;

/**
 * @program: JefConfig
 * @description:
 * @author: Cheng Zhi
 * @create: 2022-07-15 15:03
 **/
public class FileResource extends Resource {

    protected File file;
    protected FileResource() {
        super(null);
    }
    public FileResource(URL url) {
        super(null);

        //super(url);
        try {
            file=new File(url.toURI());
        } catch (URISyntaxException e) {
            LogUtils.error(url.toString());
            throw new IllegalArgumentException(e);
        } catch (IllegalArgumentException e) {
            LogUtils.error(url.toString());
            throw e;
        }
    }

    public FileResource(File file2) {
        super(null);
        this.file=file2;
        try {
            super.url=file2.toURI().toURL();
        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        }
    }

    public File getFile() {
        return file;
    }
}
